import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store/';
import components from './components'; //加载公共组件
Vue.config.productionTip = false
Object
  .keys(components)
  .forEach((key) => {
    var name = key.replace(/(\w)/, (v) => v.toUpperCase()) //首字母大写
    Vue.component(`v${name}`, components[key])
  })
router.beforeEach((to, from, next) => {
  let isLogin = Boolean(store.state.info.isLogin)
  if (!isLogin && to.fullPath !== '/login') {
    return next('/login');
  }
  next();
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})